namespace FineCollection.Intf
{



    /** 
     * \defgroup CollectionExceptions Collection Exceptions 
     * \ingroup FineCollection
     */
    /*@{ */
    #region CollectionExceptions 

    /**
     * Throws when accessed index is out of bounds, or when collection is empty.
     **/ 
    public class IndexOutOfBoundsException : System.Exception
    {
        /**
         * Requested index.
         **/
        public readonly int Index;
        
        /**
         * The first possible index.
         **/ 
        public readonly int LowerBound;
        
        /**
         * The last possible index.
         **/
        public readonly int UpperBound;
        
        
        public IndexOutOfBoundsException(int index, int lowerBound, int upperBound)
            : base (
                string.Format("Index is out of ranges. Given index: {0}. Ranges: {1}..{2}.", index, lowerBound, upperBound)
                )
        {
            this.Index = index;
            this.LowerBound = lowerBound;
            this.UpperBound = upperBound;
        }
    }
    
    
    /**
     * Throws when a client attempts to access an item of an empty collection.
     **/
    public class CollectionIsEmpty : System.Exception
    {
        public CollectionIsEmpty()
            : base ("The collection is empty.")
        {}
        
        public CollectionIsEmpty(string str)
            : base (str)
        {}
    }

    
    /**
     * Throws when a client attempts to add a key-value pair to a map
     * but this map already contains a pair with the same key but another value.
     **/
    public class ValueMismatchKeyException : System.Exception
    {
        public ValueMismatchKeyException(string str)
            : base(str)
        { }
    }
    

    /**
     * Throws when a client attempts to add a duplicated value into a set.
     **/
    public class DuplicatesFoundException : System.Exception
    {
        public DuplicatesFoundException()
            : base("Gived data have duplicates.")
        { }

        public DuplicatesFoundException(string msg)
            : base(msg)
        { }
    }

    
    /**
     * Throws when a client attempts to add nulls into a set.
     **/
    public class NullItemsException : System.Exception
    {
        public NullItemsException()
            : base("Null items.")
        { }
    }


    /// <summary>
    /// Raises when used <see cref="RIterator{T}.Next()"/> and when all items have already been iterated.
    /// </summary>
    public class OutOfCollectionException : System.Exception
    {
        public OutOfCollectionException(string message)
            : base(message)
        { }
    }


    /// <summary>
    /// Raised when one get collection iterator, 
    /// then modified the collection, 
    /// then attempted to use that iterator.
    /// </summary>
    public class CollectionModifiedException : System.Exception
    {
        public CollectionModifiedException()
            : base("Collection has been modified.")
        { }
    }


    /**
     * In an ideal world, this exception showd be never thrown.
     * But the World is not ideal...
     **/
    public class InternalAlgorythmError : System.Exception
    {
        public InternalAlgorythmError(string message) 
            : base(message)
        {}
    }


    #endregion
    /*@}*/


}